package com.tc.mapper;

import com.tc.messageDto.DainaCenter;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DainaMapper {
    //新增代拿订单
    @Insert("insert into daina_center(id, user_id, publish, order_number, username, place, iphone) values(#{id},#{userId},#{publish},#{orderNumber},#{username},#{place},#{iphone})")
    void addDaina(DainaCenter dainaCenter);
    //获取所有代拿订单
    @Select("select * from daina_center limit #{number},7")
    List<DainaCenter> getAllDaina(Integer number);
    //判断该订单是否被人选择
    @Select("select * from daina_center where id=#{id}")
    DainaCenter selectMakeId(String id);
    //修改该订单的代拿状态
    @Update("update daina_center set take_user=#{param2} where order_number=#{orderNumber}")
    void updateOrderState(String orderNumber, Integer takeUserId);
    //把在订单在代拿中心移除
    @Delete("delete from daina_center where order_number=#{orderNumber}")
    void deleteDainaOrder(String orderNumber);
    //把会话id存入mysql
    @Insert("insert into chat_session(id, user_id1, user_id2) values(#{param1},#{param2},#{param3})")
    void addChatSession(Integer id, Integer valueOf, Integer userId);
    //查询与自己有关的userid2
    @Select("select user_id2 from chat_session where user_id1=#{id}")
    List<Integer> getChatObj1(Integer id);
    //查询与自己有关的userid1
    @Select("select user_id1 from chat_session where user_id2=#{id}")
    List<Integer> getChatObj2(Integer id);
    @Select("select id from chat_session where id=#{id}")
    Integer selectSessionId(Integer id);
}
